package com.quanxiaoha.weblog.common.domain.dos;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * @author: 犬小哈
 * @url: www.quanxiaoha.com
 * @date: 2025-01-28 15:00
 * @description: 邮箱验证码实体类
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("t_email_verification_code")
public class EmailVerificationCodeDO {

    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 验证码
     */
    private String code;

    /**
     * 验证码类型：1：登录 2：注册 3：找回密码 4：绑定邮箱
     */
    private Integer type;

    /**
     * 是否已使用：0：未使用 1：已使用
     */
    private Boolean used;

    /**
     * 过期时间
     */
    private LocalDateTime expireTime;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 验证码类型枚举
     */
    public enum Type {
        LOGIN(1, "登录"),
        REGISTER(2, "注册"),
        RESET_PASSWORD(3, "找回密码"),
        BIND_EMAIL(4, "绑定邮箱");

        private final int code;
        private final String description;

        Type(int code, String description) {
            this.code = code;
            this.description = description;
        }

        public int getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }
}
